home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / PROGRAM / OPTANS10.ARJ / OPTANSI.H < prev    next >
C/C++ Source or Header  |  1992-06-13  |  5KB  |  178 lines

  1. /******************************************************************************
  2.                                                              OptANSI Library
  3.                                                  Copyright 1992 Michael Dannov
  4. This source is subject to all restrictions specified by the licensing agreement
  5. ******************************************************************************/
  6.  
  7.  
  8. #if !defined(__OPTANSI_H)
  9. #define __OPTANSI_H
  10.  
  11. #ifdef __cplusplus
  12. #define EXTERN extern "C"
  13. #else
  14. #define EXTERN extern
  15. #endif
  16.  
  17. #if defined(_aFN)
  18. /* COMPILATION RULES: ONLY VALID WHILE COMPILING SOURCE CODE */
  19.  
  20. // Defined if source code is registered. 0 only for creation of demo library.
  21. #define REGISTERED 0
  22. // Set this define to 1 if you want size considerations to supercede speed
  23. #define SIZE 0
  24. // Set this if you wish to compile in NANSI function extensions
  25. #define NANSI 0
  26.  
  27. #else                // For external code
  28.  
  29. EXTERN char ashortcuts;
  30. EXTERN char axpos;
  31. EXTERN char aypos;
  32. EXTERN char acurattr;
  33.  
  34. #endif    // _aFN
  35.  
  36.  
  37. /* Compilation Definitions */
  38.  
  39. // ashortcuts flags
  40. #define aBKSP        1
  41. #define aLF            2
  42. #define aCR            4
  43. #define aCLRSCR    8
  44. #define aRESET    64
  45. #define aNANSI    128
  46.  
  47. #define anotshort(no)        ashortcuts=(255-no)
  48. #define ashort(is)            ashortcuts=(is);
  49. #define ashortdos()            ashortcuts=(aBKSP | aCR | !aLF | !aCLRSCR | aRESET)
  50. #define ashorttelecom()    ashortcuts=(!aBKSP | aCR | aLF | aCLRSCR | aRESET);
  51.  
  52.  
  53. /* User Types */
  54. #if !defined(__COLORS)
  55. #define __COLORS
  56. enum COLORS {
  57.         BLACK,          /* dark colors */
  58.         BLUE,
  59.         GREEN,
  60.         CYAN,
  61.         RED,
  62.         MAGENTA,
  63.         BROWN,
  64.         LIGHTGRAY,
  65.         DARKGRAY,       /* light colors */
  66.         LIGHTBLUE,
  67.         LIGHTGREEN,
  68.         LIGHTCYAN,
  69.         LIGHTRED,
  70.         LIGHTMAGENTA,
  71.         YELLOW,
  72.         WHITE
  73. };
  74. #define BLINK       128 /* blink bit */
  75. #endif
  76. #define HIGHLIGHT        8        /* highlight bit */
  77. #define ATTR(fore, back)   (char)((back<<4) | fore)
  78.  
  79. struct acolorset {
  80.     unsigned fr:3;    //    Foreground Color (0-7)
  81.     unsigned h: 1;    //    Highlight bit (0-1)
  82.     unsigned bk:3;    //    Background Color (0-7)
  83.     unsigned b: 1;    //    Blinking bit (0-1)
  84. };
  85.  
  86. union acolorunion {
  87.     struct acolorset bf;
  88.     char clr;
  89. };
  90.  
  91. #define SKEY(key)        (key<<8)
  92.  
  93. #define ESC            27
  94. #define SP_ONE    255
  95.  
  96. #if !defined(__CONIO_H)
  97. enum text_modes { BW40=0, C40, BW80, C80 };
  98. #endif
  99.  
  100. enum agraphic_modes { G320_200=4, G320_200G, G640_200BW, aCURSORWRAP,
  101.     G320_200V=13, G640_200V, G640_350V=16, G640_480BWV, G640_480V, G300_200V,
  102.     ROWS43=43, ROWS50=50, aBIOSTTY=97, aFASTSCROLL, aGRAPHICSCURSOR };
  103. #define aWRITE_TTY        aBIOSTTY
  104. #define aBIOSTTY            aBIOSTTY
  105.  
  106. /* Prototypes */
  107. int ainit();
  108.  
  109. char * agotoxy(char x, char y);
  110. char * adown(char y);
  111. char * aleft(char x);
  112. char * asavecursor();
  113. char * arestorecursor();
  114. char * aclrscr();
  115. char * aclreol();
  116.  
  117. char * acolor(char nc);
  118. char * ahighlight();
  119. char * ablink();
  120.  
  121. char * acmd(char num, char cmd);
  122. unsigned awherexy(char *s);
  123. char * atest();
  124. char * atest1();
  125. int aresult(char *s);
  126. int aresult1();
  127. int aresult2();
  128. char *akeyboard(int key, char *str, char *buf);
  129. char *amode(int mode, char cmd);
  130.  
  131.  
  132. #define atextattr(nc)                acolor(nc)
  133. #define atextcolor(nc)            acolor( (acurattr&240) | nc )
  134. #define aforcecolor(nc)            acurattr^=255;acolor(nc)
  135. #define atextbackground(nc)    acolor( (acurattr&15) | (nc<<4) )
  136. #define ahighvideo()                ahighlight()
  137. #define anohighlight()            acolor(acurattr & 247)
  138. #define alowvideo()                    anohighlight()
  139. #define anormvideo()                anohighlight()
  140. #define anoblink()                    acolor(acurattr & 127)
  141. #define aresetcolor()                acolor(7)
  142. #define aunderline(fn)            acmd(4, 'm'); fn
  143. #define areverse(fn)                acmd(7, 'm'); fn
  144. #define ainvisible(fn)            acmd(8, 'm'); fn
  145.  
  146. #define aforcegotoxy(x, y)    axpos=255;aypos=255;agotoxy(x, y)
  147. #define aup(y)                            acmd(y, 'A'); aypos += y
  148. #define aright(x)                        acmd(x, 'C'); axpos += x
  149. #define ahome()                            agotoxy(1, 1)
  150.  
  151. #define aclrbol()                        acmd(SP_ONE, 'K')    // Rare Implementation
  152. #define aclrline()                    acmd(2, 'K')            // Rare Implementation
  153. #define aclrsrnbelow()            acmd(0, 'J')            // Rare Implementation
  154. #define aclrsrnabove()            acmd(SP_ONE, 'J')    // Rare Implementation
  155.  
  156. #define asetmode(mode)            amode(mode, 'h')
  157. #define aresetmode(mode)        amode(mode, 'l')
  158. #define atextmode(mode)            asetmode(mode)
  159. #define acursorwrap()                asetmode(7)
  160. #define anocursorwrap()            aresetmode(7)
  161.  
  162. #define aupdatexy()                    axpos=wherex(); aypos=wherey()
  163. #define aupdatexy1()                axpos=*(char far *)(0x00000450L)+1; aypos=*(char far *)(0x00000451L)+1
  164.                                                         // _wherexy(); y=_AL+1; x=_AH+1
  165.  
  166. // for NANSI and FANSI
  167. #define adim()                            alowvideo()
  168. #define anoinvisible(fn)        acmd(28, 'm'); fn
  169. #define ainsline(y)                 acmd(y, 'L')    // NANSI Implementation
  170. #define adelline(y)                 acmd(y, 'M')    // NANSI Implementation
  171. #define ainschar(x)                 acmd(x, '@')    // NANSI Implementation
  172. #define adelchar(x)                 acmd(x, 'P')    // NANSI Implementation
  173.  
  174.  
  175.  
  176. #endif        // _OPTANSI_H
  177.  
  178.